<template>
  <div>
    <divider>人员列表</divider>
    <div style="padding:2px 20px 2px 2px;float:right">
        <x-button type="primary" mini :disabled="submitDisable" @click.native="submitAll()">一键审批</x-button>
    </div
    <group>
      <div>
      <x-table :cell-bordered="false" :content-bordered="false" style="background-color:#fff;">
        <thead>
          <tr style="background-color: #F7F7F7">
            <th>姓 名</th>
            <th>申请积分</th>
            <th>未处理</th>
          </tr>
        </thead>
        <tbody v-for="(data,index) in memberlist">
          <tr>
            <td>{{data.name}}</td>
            <td style="padding:2px 5px 2px 30px;">{{data.applyScore}}</td>
            <td v-if="data.selfScore==null">暂无</td>
            <td v-if="data.selfScore!=null" style="padding:2px 5px 2px 30px;"><router-link :to="'/tabbar/apply-list-ad?userId='+data.userId+'&name='+data.name+'&applyScore='+data.applyScore+'&selfScore='+data.selfScore">{{data.selfScore}}</router-link></td>
          </tr>
        </tbody>
      </x-table>
      </div>
    </group>
    <toast v-model="status" type='text'>没有新的积分</toast>
  </div>
</template>

<script>
import { Group, Badge, XTable, Divider, XButton, Loading, Toast} from 'vux'

export default {
  components: {
    Group,
    Badge,
    XTable,
    Divider,
    XButton,
    Loading,
    Toast
  },
  data () {
    var ms_staffId = localStorage.getItem('ms_staffId')
    return {
      memberlist: [],
      showContent001: false,
      submitDisable: false,
      status: false,
      staffIdOnLogin: ms_staffId
    }
  },
  mounted: function () {
    this.getMember()
    console.log(123213)
  },
  methods: {
    getMember: function () {
      var self = this
      self.$ajax({
        method: 'get',
        url: '../wx/userAdditional/user',
        params: {
          staffId: self.staffIdOnLogin,
          status: '2'
        }
      })
      .then(function (res) {
        self.memberlist = res.data
      })
      .catch(function (err) {
        console.log(err)
      })
    },
    submitAll: function () {
      var self = this
      self.submitDisable = true
      self.$vux.loading.show({
        text: 'Loading'
      })
      self.$ajax({
        method: 'get',
        url: '../wx/userAdditional/submit/all',
        params: {
          staffId: self.staffIdOnLogin,
        }
      })
      .then(function (res) {
        if (res.data == true) {
          self.$vux.loading.hide()
          self.$router.push('/work')
        }else{
          self.$vux.loading.hide()
          self.status = true
        }
      })
      .catch(function (err) {
        console.log(err)
      })
    }
  }
}
</script>
